﻿using System.Collections;
using DG.Tweening;
using FlowCanvas;
using FlowCanvas.Nodes;
using NodeCanvas.Framework;
using UnityEngine;

namespace Yoozoo.Gameplay.Liberty.StreetEvent
{
    public class TweenInputCameraAngle : LatentActionNodeBase
    {
        public BBParameter<Vector3> cameraAngle;
        public BBParameter<float> speed;
        public BBParameter<Ease> easeType;

        protected bool tweenComplete = false;
        
        public IEnumerator Invoke()
        {
            tweenComplete = false;
            BlueprintUtils.PlayerController.inputCamera.TweenCameraAngle(cameraAngle.value,speed.value,easeType.value,
                () =>
                {
                    tweenComplete = true;
                });
            
            yield return new UnityEngine.WaitUntil(() =>
            {
                return tweenComplete;
            });
        }
        
        protected override void OnRegisterDerivedPorts(FlowNode node)
        {
            node.AddFlowInput("In", (f) => { Begin(Invoke(), f); });
        }
    }
}